package com.tx.axure.tkaxureweb.vo;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

/**
 * @Author ChenZhaoHui
 * @Date 2022/6/26 19:59
 */
@Data
@AllArgsConstructor
@Slf4j
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public class ResultVoStr {
    private Integer error;//0正确
    private String msg;
    private String data;
    private Exception exception;

    public ResultVoStr() {
        this.error = 0;
        this.msg="success";
        this.data="";

    }

    public ResultVoStr(Integer error) {
        this.error = error;
        this.msg="fail";
        this.data="";
    }

    public ResultVoStr(Integer error,String msg) {
        this.error = error;
        this.msg=msg;
        this.data="";
    }

    public ResultVoStr(Exception e){
        this.error = -1;
        this.msg="fail";
        this.data="";
        this.exception=e;
    }

    public String toJsonString() {
        return "{" +
                "'error':" + error +
                ", 'msg':'" + msg + '\'' +
                ", 'data':'" + data + '\'' +
                '}';
    }
}
